package com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean;

import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;

import java.io.Serializable;

import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.A_LI_PAY;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.BANK_PAY;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.ON_PAYING;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.PAYED_WAITING;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.TRANSFER_OVER;
import static com.example.shushiyunsst.fragment.main.home.child.icon_sst.bean.PayTypeConfigKt.WEI_CHAT_PAY;

public class OrderBean implements Serializable {

    public static final int BANK_PAY_ = BANK_PAY;

    public static final int A_LI_PAY_ = A_LI_PAY;

    public static final int WEI_CHAT_PAY_ = WEI_CHAT_PAY;

    /**
     * toid : 11
     * txNums : 333
     * statusDesc : 待支付
     * totalPrice : 339.66
     * txid : 14
     * orderStatus : 0
     * txType : 1
     * realName : 姐姐这就是
     * txNo : TX20201018160950926236835
     * payType : 0
     * createTime : 2020-10-18 16:14:42
     * price : 1.02
     * uidBuyer : 2
     * uidSeller : 2
     * tokenType : SST
     */


    @JSONField(name = "toid")
    private int toid;

    @JSONField(name = "txid")
    private int txid;

    @JSONField(name = "txNo")
    private String txNo;

    @JSONField(name = "tokenType")
    private String tokenType;

    @JSONField(name = "txType")
    private int txType;

    @JSONField(name = "price")
    private double price;

    @JSONField(name = "txNums")
    private double txNums;

    @JSONField(name = "totalPrice")
    private double totalPrice;

    @JSONField(name = "statusDesc")
    private String statusDesc;

    @JSONField(name = "orderDesc")
    private String orderDesc;

    @JSONField(name = "createTime")
    private String createTime;

    @JSONField(name = "realName")
    private String realName;

    @JSONField(name = "uidBuyer")
    private int uidBuyer;

    @JSONField(name = "uidSeller")
    private int uidSeller;

    @JSONField(name = "payUrl")
    private String payUrl;

    //订单状态 0-待付款 1-已付款待放币 2-买家取消 3-卖家取消 4-交易完成 5-争议中
    @JSONField(name = "orderStatus")
    private int orderStatus;

    //1-微信 2-支付宝 3-银行卡
    @JSONField(name = "payType")
    private int payType;

    //0-买家 1-卖家
    @JSONField(name = "isSeller")
    private int isSeller;

    @JSONField(name = "account")
    private String account;

    public void setTxNums(double txNums) {
        this.txNums = txNums;
    }

    public void setOrderDesc(String orderDesc) {
        this.orderDesc = orderDesc;
    }

    public String txNumsStr() {
        return txNums + "";
    }

    public String getPayUrl() {
        return payUrl;
    }

    public void setPayUrl(String payUrl) {
        this.payUrl = payUrl;
    }

    public int getIsSeller() {
        return isSeller;
    }

    public void setIsSeller(int isSeller) {
        this.isSeller = isSeller;
    }

    public String getAccount() {
        return account;
    }

    public void setAccount(String account) {
        this.account = account;
    }

    public String getTxNo22() {
        return "订单号 " + txNo;
    }

    public String getOrderNo() {
        return "订单号 " + txNo;
    }

    public String getPriceStr() {
        return price + "";
    }

    public String getTotalPriceStr() {
        return totalPrice + "";
    }

    public String getTxNumStr() {
        return txNums + "";
    }

    public int getToid() {
        return toid;
    }

    public void setToid(int toid) {
        this.toid = toid;
    }

    public double getTxNums() {
        return txNums;
    }

    public String getTxNums22() {
        return String.valueOf(txNums);
    }


    public void setTxNums(int txNums) {
        this.txNums = txNums;
    }

    public String getStatusDesc() {
        return statusDesc;
    }

    public void setStatusDesc(String statusDesc) {
        this.statusDesc = statusDesc;
    }

    public double getTotalPrice() {
        return totalPrice;
    }

    public String getPrice22() {
        return String.valueOf(price);
    }

    public String getTotalPrice22() {
        return String.valueOf(totalPrice);
    }


    public void setTotalPrice(double totalPrice) {
        this.totalPrice = totalPrice;
    }

    public int getTxid() {
        return txid;
    }

    public void setTxid(int txid) {
        this.txid = txid;
    }

    public int getOrderStatus() {
        return orderStatus;
    }

    public void setOrderStatus(int orderStatus) {
        this.orderStatus = orderStatus;
    }

    public int getTxType() {
        return txType;
    }

    public void setTxType(int txType) {
        this.txType = txType;
    }

    public String getRealName() {
        return realName;
    }

    public void setRealName(String realName) {
        this.realName = realName;
    }

    public String getTxNo() {
        return txNo;
    }

    public void setTxNo(String txNo) {
        this.txNo = txNo;
    }

    public int getPayType() {

        return payType;
    }

    public int getPayTypeUI(PaymentBean paymentBean) {
        if (payType != WEI_CHAT_PAY_ && payType != BANK_PAY_ && payType != A_LI_PAY_) {
            if (paymentBean.getIsSupportBank() == 1) {
                payType = BANK_PAY_;
            } else if (paymentBean.getIsSupportWx() == 1) {
                payType = WEI_CHAT_PAY_;
            } else if (paymentBean.getIsSupportAipay() == 1) {
                payType = A_LI_PAY_;
            }
        }
        return payType;
    }

    public void setPayType(int payType) {
        this.payType = payType;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public int getUidBuyer() {
        return uidBuyer;
    }

    public void setUidBuyer(int uidBuyer) {
        this.uidBuyer = uidBuyer;
    }

    public int getUidSeller() {
        return uidSeller;
    }

    public void setUidSeller(int uidSeller) {
        this.uidSeller = uidSeller;
    }

    public String getTokenType() {
        return tokenType;
    }

    public void setTokenType(String tokenType) {
        this.tokenType = tokenType;
    }

    public String getOrderDesc() {
        if (TextUtils.isEmpty(orderDesc)) {
            return statusDesc;
        }
        return orderDesc;
    }

    public boolean isShowOperation() {
        return orderStatus == ON_PAYING
                || orderStatus == PAYED_WAITING
                || (orderStatus == TRANSFER_OVER && isSeller == 0);
//            return isSeller == 1 && orderStatus == PAYED_WAITING;
    }
}